﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace BenevolentSunData
{
    public class Material
    {
        
        [ContentSerializer(Optional = true)]
        public Vector3 DiffuseColor;

        [ContentSerializer(Optional = true)]
        public Vector3 SpecularColor;

        [ContentSerializer(Optional = true)]
        public float SpecularPower;

        [ContentSerializer(Optional = true)]
        public Vector3 EmissiveColor;

        [ContentSerializer(Optional = true)]
        public float Alpha;

        public Material()
        {
            DiffuseColor = Color.White.ToVector3();
            SpecularColor = new Vector3(0.0f, 0.0f, 0.0f);//Color.White.ToVector3();
            EmissiveColor = Color.Black.ToVector3();
            SpecularPower = 60f;
            Alpha = 1f;
        }

        public void LoadContent(ContentManager content)
        {
            if (TextureName != null)
                content.Load<Texture2D>(TextureName);
        }

        public Material Clone()
        {
            Material skin = new Material();

            skin.TextureName = TextureName;
            skin.DiffuseColor = new Vector3(DiffuseColor.X, DiffuseColor.Y, DiffuseColor.Z);
            skin.SpecularColor = new Vector3(SpecularColor.X, SpecularColor.Y, SpecularColor.Z);
            skin.SpecularPower = SpecularPower;
            skin.EmissiveColor = new Vector3(EmissiveColor.X, EmissiveColor.Y, EmissiveColor.Z);
            skin.AmbientLightColor = new Vector3(AmbientLightColor.X, AmbientLightColor.Y, AmbientLightColor.Z);
            skin.Alpha = Alpha;
            skin.Texture = Texture;

            return skin;
        }
        
    
        
    }
}